import request from '@/api/request'
import { AxiosPromise } from 'axios'

enum API {
    BASE_URL = "/system/depts/"
}

export const getDeptTreeApi = (): AxiosPromise<any> => {
    return request.get<any>(API.BASE_URL+"tree")
}

export const searchDeptApi = (name: string): AxiosPromise<any> => {
    return request.get<any>(API.BASE_URL + "search", {
        params: {
            name
        }
    })
}

export const createDeptApi = (params: any): AxiosPromise<any> => {
    return request.post<any>(API.BASE_URL, params)
}

export const updateDeptApi = (params: any): AxiosPromise<any> => {
    return request.put<any>(API.BASE_URL, params)
}

export const deleteDeptByIdApi = (id: string|number): AxiosPromise<any> => {
    return request.delete<any>(API.BASE_URL + '/' + id)
}